<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
       {include="style"}
	   <style>
	   .cache-s{
	   width:6rem !important;
	   }
	   #msg{
	       margin-left: 20px;
		line-height: 24px;
	   }
	   .layui-btn-gray {
		    background-color: #b73535;
		}
	   </style>
    </head>
    <body>
    <div class="x-body layui-anim layui-anim-up">
      <div class="layui-card">
		<div class="layui-card-body">
        <fieldset class="layui-elem-field">
            <div class="layui-field-box">
                <div class="layui-col-md12">
				<blockquote class="layui-elem-quote">{if($webconf['iscachepage']==1)}您已开启【缓存完整页面】，更新静态HTML需要预留足够的空间，如：总内存500M，已用280M（过半），不建议生成HMTL，可能会导致内存不够！<br>可以去【系统设置】-【高级设置】-【缓存完整页面】进行关闭{else}请确定空间内存是否足够，如果不够，可以开启【缓存完整页面】，也能达到静态访问打开页面速度！{/if}</blockquote>
                    <form class="layui-form " action="">
					
					<table class="layui-table">
					<tr>
					<th>模块名称</th>
					<th>指定栏目</th>
					<th>输出范围</th>
					<th>操作</th>
					
					</tr>
					<tr>
					<td>栏目模块<input name="model[]" value="classtype" type="hidden"></td>
					<td><select class="tid" lay-search name="tid[]"  >
						<option value="0">所有栏目</option>
					   {foreach $classtypetree as $v}
					   <option value="{$v['id']}">{fun str_repeat('--', $v['level'])}{$v['classname']}</option>
					   {/foreach}
						</select>
						</td>
					<td><select class="isshow" name="isshow[]"  >
						<option value="1">显示的栏目</option>
						<option value="2">所有的栏目</option>
						</select>
						</td>
					<td><button onclick="tohtml(this)" data="classtype" class="layui-btn" type="button">生成电脑静态</button>
					<button onclick="tohtmlmobile(this)" data="classtype" class="layui-btn  layui-btn-warm" type="button">生成手机静态</button>

					<button onclick="clearhtml(this)" data="classtype" class="layui-btn layui-btn-gray" type="button">清理电脑静态HTML</button>
					<button onclick="clearhtmlmobile(this)" data="classtype" class="layui-btn  layui-btn-gray" type="button">清理手机静态HTML</button>

					</td>
					
					</tr>
					
					<tr>
					<td>文章模块<input name="model[]" value="article" type="hidden"></td>
					<td><select class="tid" lay-search name="tid[]"  >
						<option value="0">所有栏目</option>
					   {foreach $classtypetree as $v}
					   {if($v['molds']=='article')}
					   <option value="{$v['id']}">{fun str_repeat('--', $v['level'])}{$v['classname']}</option>
					   {/if}
					   {/foreach}
						</select>
						</td>
					<td><select class="isshow" name="isshow[]"  >
						<option value="1">显示的文章</option>
						<option value="2">所有的文章</option>
						</select>
						</td>
					<td><button onclick="tohtml(this)" data="article" class="layui-btn" type="button">生成电脑静态</button>
					<button onclick="tohtmlmobile(this)" data="article" class="layui-btn  layui-btn-warm" type="button">生成手机静态</button>
					<button onclick="clearhtml(this)" data="article" class="layui-btn layui-btn-gray" type="button">清理电脑静态HTML</button>
					<button onclick="clearhtmlmobile(this)" data="article" class="layui-btn  layui-btn-gray" type="button">清理手机静态HTML</button>
					</td>
					
					</tr>
					<tr>
					<td>商品模块<input name="model[]" value="product" type="hidden"></td>
					<td><select class="tid" lay-search name="tid[]"  >
						<option value="0">所有栏目</option>
					   {foreach $classtypetree as $v}
					   {if($v['molds']=='product')}
					   <option value="{$v['id']}">{fun str_repeat('--', $v['level'])}{$v['classname']}</option>
					   {/if}
					   {/foreach}
						</select>
						</td>
						<td><select class="isshow" name="isshow[]"  >
						<option value="1">显示的商品</option>
						<option value="2">所有的商品</option>
						</select>
						</td>
					<td><button onclick="tohtml(this)" data="product" class="layui-btn" type="button">生成电脑静态</button>
					<button onclick="tohtmlmobile(this)" data="product" class="layui-btn  layui-btn-warm" type="button">生成手机静态</button>
					<button onclick="clearhtml(this)" data="product" class="layui-btn layui-btn-gray" type="button">清理电脑静态HTML</button>
					<button onclick="clearhtmlmobile(this)" data="product" class="layui-btn  layui-btn-gray" type="button">清理手机静态HTML</button>
					</td>
					
					</tr>
					{loop table="molds" sys="0" as="v"}
					{if($v['biaoshi']!='links' && $v['biaoshi']!='tags')}
					<tr>
					<td>{$v['name']}模块<input name="model[]" value="{$v['biaoshi']}" type="hidden"></td>
					<td><select class="tid" lay-search name="tid[]"  >
						<option value="0">所有栏目</option>
						{foreach $classtypetree as $vv}
					   {if($vv['molds']==$v['biaoshi'])}
					   <option value="{$v['id']}">{fun str_repeat('--', $vv['level']), $vv['classname']}</option>
					   {/if}
					   {/foreach}
						</select>
						</td>
					<td><select class="isshow" name="isshow[]"  >
						<option value="1">显示的{$v['name']}</option>
						<option value="2">所有的{$v['name']}</option>
						</select>
						</td>
					<td><button onclick="tohtml(this)" data="{$v['biaoshi']}" class="layui-btn" type="button">生成电脑静态</button>
					<button onclick="tohtmlmobile(this)" data="{$v['biaoshi']}" class="layui-btn  layui-btn-warm" type="button">生成手机静态</button>
					<button onclick="clearhtml(this)" data="{$v['biaoshi']}" class="layui-btn layui-btn-gray" type="button">清理电脑静态HTML</button>
					<button onclick="clearhtmlmobile(this)" data="{$v['biaoshi']}" class="layui-btn  layui-btn-gray" type="button">清理手机静态HTML</button>
					</td>
					</tr>
					{/if}
					{/loop}
					
					
					
					
					<input type="hidden" name="type" value="2">
					
					</table>
					
					
					  
					  <div class="layui-form-item" style="text-align:center;">
						 <button class="layui-btn" lay-submit lay-filter="formDemo">批量生成电脑静态</button>
						  <button class="layui-btn  layui-btn-warm" lay-submit lay-filter="formDemomobile">批量生成手机静态</button>
						  <button class="layui-btn layui-btn-gray" lay-submit lay-filter="clearformDemo">批量清理电脑静态</button>
						  <button class="layui-btn  layui-btn-gray" lay-submit lay-filter="clearformDemomobile">批量清理手机静态</button>
					  </div>
					</form>
                </div>
            </div>
        </fieldset>
       </div>
       </div>
       
    </div>
        <script>
		layui.use(['laydate','form','layer','upload'], function(){
                $ = layui.jquery;
              var form = layui.form
              ,layer = layui.layer;
			  laydate = layui.laydate;
			  var upload = layui.upload;
			     //监听提交
              form.on('submit(formDemo)', function(data){
				//console.log(data.field);return false;
					$.ajax({
						 url:"{fun U('Index/tohtml')}?terminal=pc",
						 dataType:"json",
						 async:true,
						 data:data.field,
						 type:"POST",
						 beforeSend:function(){
							
							layer.msg('正在处理~');
							
						},
						 success:function(r){
							if(r.code==1){
								layer.alert(r.msg);
							}else{
								layer.msg('正在准备生成静态，请不要关闭页面~',function(){
									window.location.reload();
								});
							}
							
						},
						 complete:function(){
						//请求完成的处理
						},
						 error:function(){
						//请求出错处理
						}

								
						
					})
                return false;
              });
			  
			   form.on('submit(formDemomobile)', function(data){
					$.ajax({
						 url:"{fun U('Index/tohtml')}?terminal=mobile",
						 dataType:"json",
						 async:true,
						 data:data.field,
						 type:"POST",
						 beforeSend:function(){
							//请求前的处理
							layer.msg('正在处理~');
						},
						 success:function(r){
							//console.log(r);
							if(r.code==1){
								layer.alert(r.msg);
							}else{
								layer.msg('正在准备生成静态，请不要关闭页面~',function(){
									window.location.reload();
								});
							}
							
						},
						 complete:function(){
						//请求完成的处理
						},
						 error:function(){
						//请求出错处理
						}

								
						
					})
				
				
				
				
               
                return false;
              });

			  form.on('submit(clearformDemo)', function(data){
				//console.log(data.field);return false;
					$.ajax({
						 url:"{fun U('Index/tohtml')}?terminal=pc&clearhtml=1",
						 dataType:"json",
						 async:true,
						 data:data.field,
						 type:"POST",
						 beforeSend:function(){
							
							layer.msg('正在处理~');
							
						},
						 success:function(r){
							if(r.code==1){
								layer.alert(r.msg);
							}else{
								layer.msg('正在准备清理电脑端静态HTML，请不要关闭页面~',function(){
									window.location.reload();
								});
							}
							
						},
						 complete:function(){
						//请求完成的处理
						},
						 error:function(){
						//请求出错处理
						}

								
						
					})
                return false;
              });

               form.on('submit(clearformDemomobile)', function(data){
					$.ajax({
						 url:"{fun U('Index/tohtml')}?terminal=mobile&clearhtml=1",
						 dataType:"json",
						 async:true,
						 data:data.field,
						 type:"POST",
						 beforeSend:function(){
							//请求前的处理
							layer.msg('正在处理~');
						},
						 success:function(r){
							//console.log(r);
							if(r.code==1){
								layer.alert(r.msg);
							}else{
								layer.msg('正在准备清理手机端静态HTML，请不要关闭页面~',function(){
									window.location.reload();
								});
							}
							
						},
						 complete:function(){
						//请求完成的处理
						},
						 error:function(){
						//请求出错处理
						}

								
						
					})
				
				
				
				
               
                return false;
              });



		})
		
		function tohtml(t){
			var isshow = $(t).parent().prev().children('.isshow').val();
			var model = $(t).attr('data');
			var tid = $(t).parent().prev().prev().children('.tid').val();
		
			$.ajax({
				 url:"{fun U('Index/tohtml')}",
				 dataType:"json",
				 async:true,
				 data:{type:1,model:model,isshow:isshow,tid:tid,terminal:'pc'},
				 type:"POST",
				 beforeSend:function(){
					layer.msg('正在处理~');
							
				},
				 success:function(r){
					//console.log(r);
					if(r.code==1){
						layer.alert(r.msg);
					}else{
						layer.msg('正在准备生成静态，请不要关闭页面~',function(){
							window.location.reload();
						});
					}
				},
				 complete:function(){
				//请求完成的处理
				},
				 error:function(){
				
				}

						
				
			})
			
		
			
		}
		
		function tohtmlmobile(t){
			var isshow = $(t).parent().prev().children('.isshow').val();
			var model = $(t).attr('data');
			var tid = $(t).parent().prev().prev().children('.tid').val();
		
			$.ajax({
				 url:"{fun U('Index/tohtml')}",
				// dataType:"json",
				 async:true,
				 data:{type:1,model:model,isshow:isshow,tid:tid,terminal:'mobile'},
				 type:"POST",
				 beforeSend:function(){
					layer.msg('正在处理~');
							
				},
				 success:function(r){
				
					if(r.code==1){
						layer.alert(r.msg);
					}else{
						layer.msg('正在准备生成静态，请不要关闭页面~',function(){
							window.location.reload();
						});
					}
				},
				 complete:function(){
				//请求完成的处理
				},
				 error:function(){
				
				}

						
				
			})
			
		
			
		}
		function clearhtml(t){
			var isshow = $(t).parent().prev().children('.isshow').val();
			var model = $(t).attr('data');
			var tid = $(t).parent().prev().prev().children('.tid').val();
		
			$.ajax({
				 url:"{fun U('Index/tohtml')}",
				 dataType:"json",
				 async:true,
				 data:{type:1,model:model,isshow:isshow,tid:tid,terminal:'pc',clearhtml:1},
				 type:"POST",
				 beforeSend:function(){
					layer.msg('正在处理~');
							
				},
				 success:function(r){
					//console.log(r);
					if(r.code==1){
						layer.alert(r.msg);
					}else{
						layer.msg('正在准备清理电脑端静态HTML，请不要关闭页面~',function(){
							window.location.reload();
						});
					}
				},
				 complete:function(){
				//请求完成的处理
				},
				 error:function(){
				
				}

						
				
			})
			
		
			
		}

		function clearhtmlmobile(t){
			var isshow = $(t).parent().prev().children('.isshow').val();
			var model = $(t).attr('data');
			var tid = $(t).parent().prev().prev().children('.tid').val();
		
			$.ajax({
				 url:"{fun U('Index/tohtml')}",
				// dataType:"json",
				 async:true,
				 data:{type:1,model:model,isshow:isshow,tid:tid,terminal:'mobile',clearhtml:1},
				 type:"POST",
				 beforeSend:function(){
					layer.msg('正在处理~');
							
				},
				 success:function(r){
				
					if(r.code==1){
						layer.alert(r.msg);
					}else{
						layer.msg('正在准备清理手机端静态HTML，请不要关闭页面~',function(){
							window.location.reload();
						});
					}
				},
				 complete:function(){
				//请求完成的处理
				},
				 error:function(){
				
				}

						
				
			})
			
		
			
		}
		

        </script>
    </body>
</html>